import {
  deleteDeviceModel,
  getDeviceModelAll,
  getDeviceModel,
  getDeviceModelId,
  putDeviceModel,
  putDeviceModelSort
} from '@/base/api/DeviceModelApi';
import {Company} from '@/base/model/Company';
import {
  deleteDeviceSort,
  postDeviceSort,
  putDeviceSort,
  getDeviceSort,
  putDeviceSortSort
} from '@/base/api/DeviceSortApi';
import {getDevice} from '@/base/api/DevcieApi';
import {Page} from '@/base/Page';
import {getCompanyList, getCompany} from '@/base/api/CompanyApi';
import {deepAssign} from '@/base/util/Objects';
import {DevVo} from '@/base/model/DevVo';
import {DeviceModel} from '@/base/model/DeviceModel';
import {DeviceSort} from '@/base/model/DeviceSort';

export class NavBloc {
  sortDevice = new DeviceSort();
  model: any = {
    id: 0 || undefined,
    companyId: [],
    isFirmware: true,
    isSelfMotion: true,
    isSoftware: true,
    modelIcon: '',
    modelName: '',
    sortId: 0,
    createTime: '',
    updateTime: ''
  };
  modelPut: any = {
    id: 0 || undefined,
    companyId: 0 || undefined,
    isFirmware: true,
    isSelfMotion: true,
    isSoftware: true,
    modelIcon: '',
    modelName: '',
    sortId: 0 || undefined,
    createTime: '',
    updateTime: ''
  };

  loading = false;
  sortList: any = [];
  num: number = 0;
  sortId = 0
  modelId = 0


  getModel(id: number) {
    this.loading = true;
    return getDeviceModelId({id}).then((res) => {
      deepAssign(this.modelPut, res.data);
      return res;
    }).finally(() => {
      this.loading = false;
    });
  }

}
